package wangn.adt.base;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

//适用于多参数的情况，为了解决检测符的数量有多个的情况，而且Tri的第三个参数只能是对象
public class More<T> {

    private List<T> list = new ArrayList<>();

    public More(T... array){
        list.addAll(Arrays.asList(array));
    }

    public int getLength(){return list.size();}

    public T getItem(int idx){
        return idx>=getLength()?null:list.get(idx);
    }

    public void addItem(T t){
        list.add(t);
    }

    public List<T> getAllItems(){
        return list;
    }

    @Override
    public String toString(){
        StringBuilder sb = new StringBuilder();
        List<T> list = getAllItems();
        for (int i = 0 ; i < list.size(); i++){
            sb.append(list.get(i));
            if (i<list.size()-1)sb.append(",");
        }
        return sb.toString();
    }

    public boolean containsKey(T c){
        return list.contains(c);
    }
}
